package com.zy.cat.entity.app;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zy.cat.entity.primary.CatAppPVPrimary;

import lombok.Data;
import lombok.RequiredArgsConstructor;

/**
 * @info APP每日PV记录
 * @author Link
 * @date 2019-04-10 11:52
 */
@Entity
@Table(name = "zy_cat_app_pv", indexes = {
		@Index(name = "ctime", columnList = "ctime"),
		@Index(name = "mtype", columnList = "mtype"),
		@Index(name = "gtype", columnList = "gtype"),
		@Index(name = "mid", columnList = "mid"),
		@Index(name = "cmid", columnList = "cmid"),
		@Index(name = "pid", columnList = "pid"),
		@Index(name = "vscode", columnList = "vscode"),
		@Index(name = "cid", columnList = "cid")
		})
@Data
@RequiredArgsConstructor
@IdClass(CatAppPVPrimary.class)
public class CatAppPV {
	
	@Id
	@Column(columnDefinition = "VARCHAR(10) NOT NULL COMMENT '时间[APP每日PV记录]'")
	private String ctime;
	
	@Id
	@Column(columnDefinition = "INT(1) DEFAULT'-1'  COMMENT '(-1.全部、0.安卓、1.IOS)'")
    private int mtype;
	
	@Id
	@Column(columnDefinition = "INT(1) DEFAULT'0'  COMMENT '分组类型（0.总计1.APP版本2.APP渠道3.用户ID）'")
	private int gtype;
	
	@Id
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT 'APP版本号'")
	private String vscode;
	
	@Id
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT '主菜单ID'")
	private String mid;
	
	@Id
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT '子菜单ID'")
	private String cmid;
	
	@Id
	@Column(columnDefinition = "VARCHAR(32) DEFAULT '1111111111' COMMENT '用户ID'")
	private String pid;
	
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT '主菜单名称'")
	private String mname;
	
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT '子菜单名称'")
	private String cmname;

	@Id
	@Column(columnDefinition = "VARCHAR(20) DEFAULT'-'  COMMENT 'APP渠道号'")
	private String cid;
	
	@Column(columnDefinition = "BIGINT(10) DEFAULT'0' COMMENT '数量'")
	private long times;
	
	@Transient
	@Column(insertable=false)
	@JsonIgnore
	private String stime;
	
	public CatAppPV(String pid) {
		super();
		this.pid = pid;
	}
	
	@Transient
	@Column(insertable=false)
	@JsonIgnore
	private String etime;
	public CatAppPV(String ctime, int mtype, int gtype, String vscode, String mid, String cmid, String cid,
			long times,String mname, String cmname,String pid) {
		super();
		this.ctime = ctime;
		this.mtype = mtype;
		this.gtype = gtype;
		this.vscode = vscode;
		this.mid = mid;
		this.cmid = cmid;
		this.cid = cid;
		this.times = times;
		this.mname = mname;
		this.cmname = cmname;
		this.pid=pid;
	}
	public CatAppPV(String ctime, int mtype, int gtype, String vscode, String mid, String cmid, String cid,
			long times,String pid) {
		super();
		this.ctime = ctime;
		this.mtype = mtype;
		this.gtype = gtype;
		this.vscode = vscode;
		this.mid = mid;
		this.cmid = cmid;
		this.cid = cid;
		this.times = times;
		this.pid=pid;
	}
	public CatAppPV(String ctime, int mtype, int gtype, String vscode, String cid,String pid) {
		super();
		this.ctime = ctime;
		this.mtype = mtype;
		this.gtype = gtype;
		this.vscode = vscode;
		this.cid = cid;
		this.pid=pid;
	}
}
